|
자주 쓰이는 메소드및 API 를 정리합니다. |
탭으로 나뉘어져 있는 글입니다. [1][2][3] |
|
등록일:2008-03-18 14:39:24 (0%) 작성자: 제목:java.io > LineNumberReader |
|
new LineNumberReader(Reader in)
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class MainClass {
public static void main(String[] args) throws Exception {
LineNumberReader lineCounter = new LineNumberReader(new InputStreamReader(System.in));
String nextLine = null;
System.out.println("Type any text and press return. Type 'exit' to quit the program.");
try {
while ((nextLine = lineCounter.readLine()).indexOf("exit") == -1) {
if (nextLine == null)
break;
System.out.print(lineCounter.getLineNumber());
System.out.print(": ");
System.out.println(nextLine);
}
} catch (Exception done) {
done.printStackTrace();
}
}
}
|
LineNumberReader: getLineNumber()
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class MainClass {
public static void main(String[] args) throws Exception {
LineNumberReader lineCounter = new LineNumberReader(new InputStreamReader(System.in));
String nextLine = null;
System.out.println("Type any text and press return. Type 'exit' to quit the program.");
try {
while ((nextLine = lineCounter.readLine()).indexOf("exit") == -1) {
if (nextLine == null)
break;
System.out.print(lineCounter.getLineNumber());
System.out.print(": ");
System.out.println(nextLine);
}
} catch (Exception done) {
done.printStackTrace();
}
}
}
|
LineNumberReader: readLine()
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class MainClass {
public static void main(String[] args) throws Exception {
LineNumberReader lineCounter = new LineNumberReader(new InputStreamReader(System.in));
String nextLine = null;
System.out.println("Type any text and press return. Type 'exit' to quit the program.");
try {
while ((nextLine = lineCounter.readLine()).indexOf("exit") == -1) {
if (nextLine == null)
break;
System.out.print(lineCounter.getLineNumber());
System.out.print(": ");
System.out.println(nextLine);
}
} catch (Exception done) {
done.printStackTrace();
}
}
}
[2008년 03월 18일 14:49:57 수정되었습니다.] |
[본문링크] java.io > LineNumberReader
|
탭으로 나뉘어져 있는 글입니다. [1][2][3]
|
|
|
|
|
코멘트(이글의 트랙백 주소:/cafe/tb_receive.php?no=2873 |
|
|
|
|
|
|
|
|
|
Copyright byCopyright ⓒ2005, SSISO Community All Rights Reserved.
|
|
|